(({config,server,helper,components,CONST} = vinculum)=>{
  let r = React;
  let rd = ReactDOM;
	components.setTheme('bootstrap');
	//components.setTheme('amazeui');
	
	let actionName = {
		login:CONST.TABLE_PREFIX + '_login'
	};
  
  let mycom = {
    // 新增应用
    login:r.createFactory(r.createClass({
      tologin:function(e){
        let self = this;
				e.preventDefault();
				let params = {
					username:$('#username').val()
					,userpwd:$('#userpwd').val()
				};
        server.invokeAction(actionName.login,params).then(function(result){
            alert(result);
            location = config.query.appname;
        })['catch'](server.catchFun)['finally'](function(){console.log('finally');});

				return false;
      },
      render:function(){
        let self = this;
        let props = self.props;
        let state = self.state;
        let aform = r.DOM.form({onSubmit:self.tologin,className:'form'}
					,r.DOM.label({htmlFor:'username'},'用户名:')
					,components.createBase('input',{id:'username',name:'username',placeholder:'用户名'})
					,r.DOM.br()
					,r.DOM.label({htmlFor:'userpwd'},'密码:')
					,components.createBase('input',{id:'userpwd',name:'userpwd',type:'password',placeholder:'密码'})
					,r.DOM.br()
					,components.createBase('input',{type:'submit',theme:'primary',value:'登陆'})
				);
        return components.createBase('container',{}
					,components.createBase('grid',{}
						,{offset:2,xs:8,content:aform}
					)
				);
      }
    })),
    // 主页
    main:r.createFactory(r.createClass({
      getDefaultProps:function(){
        return {};
      },
      componentDidMount:function(){
        let self = this;
      },
      render:function(){
        let self = this;
        let props = self.props;
        let state = self.state;
        
        return r.DOM.div({}
					,components.createBase('navbar',{title:config.apptitle})
          ,mycom.login()
        );
      }
    }))
  };
  
  let app = {
    init:function(){
      app.initPage();
    }
    ,initPage:function(){
      rd.render(mycom.main(),$('#body').get(0));
    }
  };
  
  $(function(){
    app.init();
  });
})(vinculum);
